/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;

import static java.awt.image.ImageObserver.WIDTH;
import javax.swing.JOptionPane;
import model.dao.DaoBase;
import model.dao.ProfessorJpaController;

/**
 *
 * @author leonidia
 */
public class OpcoesAdministrador extends javax.swing.JFrame {

    DaoBase daoBase;

    /**
     * Creates new form OpcoesAdministrador
     */
    public OpcoesAdministrador(DaoBase daoBase) {
        initComponents();
        this.daoBase = daoBase;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        CadastrarTurma = new javax.swing.JRadioButton();
        ListarTurma = new javax.swing.JRadioButton();
        CadastrarDisciplina = new javax.swing.JRadioButton();
        ListarDisciplinas = new javax.swing.JRadioButton();
        CadastrarProfessor = new javax.swing.JRadioButton();
        ListarProfessor = new javax.swing.JRadioButton();
        CadastrarAluno = new javax.swing.JRadioButton();
        ListarAluno = new javax.swing.JRadioButton();
        ConsultaTurmas = new javax.swing.JRadioButton();
        VoltarMenuPrincipal = new javax.swing.JButton();
        ConsultaNDisciplina = new javax.swing.JRadioButton();
        ConsultaAlunoDisciplina = new javax.swing.JRadioButton();
        ConsultaTurmaOferecida = new javax.swing.JRadioButton();
        jLabel1 = new javax.swing.JLabel();
        EditarTurma = new javax.swing.JRadioButton();
        EditarDisciplina = new javax.swing.JRadioButton();
        EditarProfessor = new javax.swing.JRadioButton();
        EditarAluno = new javax.swing.JRadioButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        buttonGroup1.add(CadastrarTurma);
        CadastrarTurma.setText("Cadastrar Turma");
        CadastrarTurma.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CadastrarTurmaActionPerformed(evt);
            }
        });

        buttonGroup1.add(ListarTurma);
        ListarTurma.setText("Listar Turma");
        ListarTurma.setToolTipText("");
        ListarTurma.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ListarTurmaActionPerformed(evt);
            }
        });

        buttonGroup1.add(CadastrarDisciplina);
        CadastrarDisciplina.setText("Cadastrar Disciplina");
        CadastrarDisciplina.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CadastrarDisciplinaActionPerformed(evt);
            }
        });

        buttonGroup1.add(ListarDisciplinas);
        ListarDisciplinas.setText("Listar Diciplinas");
        ListarDisciplinas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ListarDisciplinasActionPerformed(evt);
            }
        });

        buttonGroup1.add(CadastrarProfessor);
        CadastrarProfessor.setText("Cadastrar Professor");
        CadastrarProfessor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CadastrarProfessorActionPerformed(evt);
            }
        });

        buttonGroup1.add(ListarProfessor);
        ListarProfessor.setText("Listar Professor");
        ListarProfessor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ListarProfessorActionPerformed(evt);
            }
        });

        buttonGroup1.add(CadastrarAluno);
        CadastrarAluno.setText("Cadastrar Aluno");
        CadastrarAluno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CadastrarAlunoActionPerformed(evt);
            }
        });

        buttonGroup1.add(ListarAluno);
        ListarAluno.setText("Listar Aluno");
        ListarAluno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ListarAlunoActionPerformed(evt);
            }
        });

        buttonGroup1.add(ConsultaTurmas);
        ConsultaTurmas.setText("Consultar turmas - alunos com suas notas e faltas");
        ConsultaTurmas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConsultaTurmasActionPerformed(evt);
            }
        });

        VoltarMenuPrincipal.setText("Voltar ao menu inicial");
        VoltarMenuPrincipal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                VoltarMenuPrincipalActionPerformed(evt);
            }
        });

        buttonGroup1.add(ConsultaNDisciplina);
        ConsultaNDisciplina.setText("Consultar o numero de disciplinas ja lecionadas por um professor");
        ConsultaNDisciplina.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConsultaNDisciplinaActionPerformed(evt);
            }
        });

        buttonGroup1.add(ConsultaAlunoDisciplina);
        ConsultaAlunoDisciplina.setText("Consultar a situação de um aluno em uma disciplina - exibir nota e faltas, e se foi aprovado ou não");
        ConsultaAlunoDisciplina.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConsultaAlunoDisciplinaActionPerformed(evt);
            }
        });

        buttonGroup1.add(ConsultaTurmaOferecida);
        ConsultaTurmaOferecida.setText("consultar numero de turmas ja oferecidas historicamente em determinada disciplina");
        ConsultaTurmaOferecida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConsultaTurmaOferecidaActionPerformed(evt);
            }
        });

        jLabel1.setText("Menu Administrador");

        buttonGroup1.add(EditarTurma);
        EditarTurma.setText("Editar Turma");
        EditarTurma.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EditarTurmaActionPerformed(evt);
            }
        });

        buttonGroup1.add(EditarDisciplina);
        EditarDisciplina.setText("Editar Disciplina");
        EditarDisciplina.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EditarDisciplinaActionPerformed(evt);
            }
        });

        buttonGroup1.add(EditarProfessor);
        EditarProfessor.setText("Editar Professor");
        EditarProfessor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EditarProfessorActionPerformed(evt);
            }
        });

        buttonGroup1.add(EditarAluno);
        EditarAluno.setText("Editar Aluno");
        EditarAluno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EditarAlunoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ListarTurma)
                    .addComponent(ListarDisciplinas)
                    .addComponent(ListarProfessor)
                    .addComponent(ListarAluno)
                    .addComponent(ConsultaNDisciplina)
                    .addComponent(ConsultaAlunoDisciplina)
                    .addComponent(ConsultaTurmaOferecida)
                    .addComponent(CadastrarAluno)
                    .addComponent(CadastrarProfessor)
                    .addComponent(CadastrarDisciplina)
                    .addComponent(CadastrarTurma)
                    .addComponent(ConsultaTurmas))
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(161, 161, 161)
                        .addComponent(VoltarMenuPrincipal))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(183, 183, 183)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(EditarTurma)
                                .addComponent(EditarProfessor)
                                .addComponent(EditarAluno)
                                .addComponent(EditarDisciplina))
                            .addComponent(jLabel1))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addGap(7, 7, 7)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(CadastrarTurma)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ListarTurma)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(CadastrarDisciplina)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ListarDisciplinas)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(CadastrarProfessor)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ListarProfessor)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(CadastrarAluno))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(EditarTurma)
                        .addGap(23, 23, 23)
                        .addComponent(EditarDisciplina)
                        .addGap(23, 23, 23)
                        .addComponent(EditarProfessor)
                        .addGap(23, 23, 23)
                        .addComponent(EditarAluno)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ListarAluno)
                .addGap(18, 18, 18)
                .addComponent(ConsultaTurmas)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ConsultaAlunoDisciplina, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ConsultaNDisciplina)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ConsultaTurmaOferecida)
                .addGap(18, 18, 18)
                .addComponent(VoltarMenuPrincipal)
                .addContainerGap(29, Short.MAX_VALUE))
        );

        ConsultaAlunoDisciplina.getAccessibleContext().setAccessibleName("jRadioButton10\t");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        jPanel1.getAccessibleContext().setAccessibleName("");
        jPanel1.getAccessibleContext().setAccessibleDescription("");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void ConsultaNDisciplinaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConsultaNDisciplinaActionPerformed
        // TODO add your handling code here:
        //calcular numero de turmas
        String nome, disciplina;
        
        nome = JOptionPane.showInputDialog("Digite o nome completo do professor");
        disciplina = JOptionPane.showInputDialog("Digite a disciplina");
        ProfessorJpaController professorJpaController= new ProfessorJpaController(null, daoBase.returnFactory());
        Integer quantidade = professorJpaController.findNDisciplina(nome,disciplina);
        if (quantidade > 0) {
            JOptionPane.showMessageDialog(this, quantidade, "Numero de turmas ja lecionadas", WIDTH);
        } else {
            JOptionPane.showMessageDialog(this, "Professor não encontrado", "Erro", WIDTH);
        }
    }//GEN-LAST:event_ConsultaNDisciplinaActionPerformed

    private void CadastrarTurmaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CadastrarTurmaActionPerformed
        // TODO add your handling code here:
        CadastrarTurma cadastrarTurma = new CadastrarTurma(daoBase);
        cadastrarTurma.run();

    }//GEN-LAST:event_CadastrarTurmaActionPerformed

    private void CadastrarDisciplinaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CadastrarDisciplinaActionPerformed
        // TODO add your handling code here:
        CadastrarDisciplina cadastrarDisciplina = new CadastrarDisciplina(daoBase);
        cadastrarDisciplina.run();
    }//GEN-LAST:event_CadastrarDisciplinaActionPerformed

    private void VoltarMenuPrincipalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VoltarMenuPrincipalActionPerformed
        dispose();
        OpcaoInicial opcaoInicial = new OpcaoInicial();
        opcaoInicial.run();
    }//GEN-LAST:event_VoltarMenuPrincipalActionPerformed

    private void CadastrarProfessorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CadastrarProfessorActionPerformed
        // TODO add your handling code here:
        CadastrarProfessor cadastrarProfessor = new CadastrarProfessor(daoBase);
        cadastrarProfessor.run();
    }//GEN-LAST:event_CadastrarProfessorActionPerformed

    private void CadastrarAlunoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CadastrarAlunoActionPerformed
        // TODO add your handling code here:
        CadastrarAluno cadastrarAluno = new CadastrarAluno(daoBase);
        cadastrarAluno.run();
    }//GEN-LAST:event_CadastrarAlunoActionPerformed

    private void ListarTurmaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ListarTurmaActionPerformed
        // TODO add your handling code here:
        ListarTurma listaTurma = new ListarTurma(daoBase);
        listaTurma.run();
    }//GEN-LAST:event_ListarTurmaActionPerformed

    private void ListarDisciplinasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ListarDisciplinasActionPerformed
        // TODO add your handling code here:
        ListarDisciplina listaDisciplina = new ListarDisciplina(daoBase);
        listaDisciplina.run();
    }//GEN-LAST:event_ListarDisciplinasActionPerformed

    private void ListarProfessorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ListarProfessorActionPerformed
        // TODO add your handling code here:
        ListarProfessor listarProfessor = new ListarProfessor(daoBase);
        listarProfessor.run();
    }//GEN-LAST:event_ListarProfessorActionPerformed

    private void ListarAlunoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ListarAlunoActionPerformed
        // TODO add your handling code here:
        ListarAluno listarAluno = new ListarAluno(daoBase);
        listarAluno.run();
    }//GEN-LAST:event_ListarAlunoActionPerformed

    private void ConsultaTurmasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConsultaTurmasActionPerformed
        // TODO add your handling code here:
       ConsultaTurmaAluno consultaTurmaAluno = new ConsultaTurmaAluno(daoBase);
       consultaTurmaAluno.run();
    }//GEN-LAST:event_ConsultaTurmasActionPerformed

    private void ConsultaTurmaOferecidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConsultaTurmaOferecidaActionPerformed
        String nome;
        nome = JOptionPane.showInputDialog("Digite o nome da disciplina");
        ProfessorJpaController professorJpaController = new ProfessorJpaController(null, daoBase.returnFactory());
        Integer numero = professorJpaController.findNumerTurm(nome);//recebe numero de turmas determinada disciplina se repete no cadastro de turmas" 
        JOptionPane.showMessageDialog(this, numero, "Numero de turmas ja lecionadas", WIDTH);
    }//GEN-LAST:event_ConsultaTurmaOferecidaActionPerformed

    private void ConsultaAlunoDisciplinaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConsultaAlunoDisciplinaActionPerformed
        ConsultaSituacaoAluno consultaSituacaoAluno = new ConsultaSituacaoAluno(daoBase);
        consultaSituacaoAluno.run();
    }//GEN-LAST:event_ConsultaAlunoDisciplinaActionPerformed

    private void EditarTurmaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EditarTurmaActionPerformed
        // TODO add your handling code here:
        EditarTurma editarTurma = new EditarTurma(daoBase);
        editarTurma.run();
    }//GEN-LAST:event_EditarTurmaActionPerformed

    private void EditarDisciplinaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EditarDisciplinaActionPerformed
        // TODO add your handling code here:
        EditarDisciplina editarDisciplina = new EditarDisciplina(daoBase);
        editarDisciplina.run();
    }//GEN-LAST:event_EditarDisciplinaActionPerformed

    private void EditarProfessorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EditarProfessorActionPerformed
        // TODO add your handling code here:
        EditarProfessor editarProfessor = new EditarProfessor(daoBase);
        editarProfessor.run();
    }//GEN-LAST:event_EditarProfessorActionPerformed

    private void EditarAlunoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EditarAlunoActionPerformed
        // TODO add your handling code here:
        EditarAluno editarAluno = new EditarAluno(daoBase);
        editarAluno.run();
    }//GEN-LAST:event_EditarAlunoActionPerformed
    public void run() {
        setVisible(true);
    }

    public void stop() {
        setVisible(false);
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton CadastrarAluno;
    private javax.swing.JRadioButton CadastrarDisciplina;
    private javax.swing.JRadioButton CadastrarProfessor;
    private javax.swing.JRadioButton CadastrarTurma;
    private javax.swing.JRadioButton ConsultaAlunoDisciplina;
    private javax.swing.JRadioButton ConsultaNDisciplina;
    private javax.swing.JRadioButton ConsultaTurmaOferecida;
    private javax.swing.JRadioButton ConsultaTurmas;
    private javax.swing.JRadioButton EditarAluno;
    private javax.swing.JRadioButton EditarDisciplina;
    private javax.swing.JRadioButton EditarProfessor;
    private javax.swing.JRadioButton EditarTurma;
    private javax.swing.JRadioButton ListarAluno;
    private javax.swing.JRadioButton ListarDisciplinas;
    private javax.swing.JRadioButton ListarProfessor;
    private javax.swing.JRadioButton ListarTurma;
    private javax.swing.JButton VoltarMenuPrincipal;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
}
